<extend name="Base/common"/>

<block name="left">
<article class="panel panel-default archive">
					<div class="panel-body">
						<h3 class="page-header">编辑原稿 <small>EDIT</small></h3>
						<h4><a href="{:ZSU('/userart/'.$userinfo['uid'],'Ucenter/userart',array('uid'=>$userinfo['uid']))}"><<返回我的文章列表</a></h4>
						
						<form editor="zswineditor" action="{:U('Ucenter/artedit')}" target="formAjax"  method="post" noenter>
						<input type="hidden" name="id" value="{$info.id}" />
							<div class="form-group">
								<input type="text" class="form-control" name="title" placeholder="在此输入标题" value="{$info.title}">
							</div>						
				
							<div class="form-group">
							
							<div class="markeditor">
								
								<textarea name="description" id="content-editor"  rows="10">{$info.description}</textarea>
                             </div>  
 <if condition="($roleauth['yesfile'] eq 1) OR $isadmin">
                            <div id="content-pic"></div>
                            </if>
							</div>
							<div class="form-group">
						<p class="help-block">选择文章分类</p>
						<select name="cid" class="form-control">
						<volist name="clist" id="vo">
						
							<if condition="$isadmin">
						
						
						<option <if condition="$vo['id'] eq $info['cid']">selected</if> value="{$vo.id}">{$vo.name}</option>
						
						
						
						
						<else />
						
						<if condition="$vo['enable'] eq 1">
						<option <if condition="$vo['id'] eq $info['cid']">selected</if> value="{$vo.id}">{$vo.name}</option>
						</if>
						
						
						
						
						</if>
						
						
						
						
						
						</volist>
						</select>							</div>
								<div class="form-group">
								  <p class="help-block">设置文章标签,回车键可以添加一个标签,最多五个标签,支持逗号和回车断开标签</p>
						 
						<div class="tags-control tagsinput"  data-inputval="{$info.tag}" data-max="5"  data-parametername="tag[]">
                         <input type="text" size="20" class="tag-input form-control" value="" />
                         </div>
                       
                         </div>

							<div class="form-group text-right">
							
							<if condition="1 neq $info['status']">
							
							
								<select name="status">
									<option <if condition="5 eq $info['status']">selected</if> value="5">草稿</option>
									
									
									<if condition="($roleauth['yesshen'] eq 2) OR $isadmin">
									<option  value="1">直接发布</option>
									<else />
									<option value="2" <eq name="info['status']" value="2">selected</eq>>等待复审</option>	
									</if>
									
									
									
															
									</select>
							</if>
							
								<button type="submit" class="btn btn-success">确认操作</button>
							</div>	
						</form>
					</div>
			 </article>
</block>			 
<block name="right"></block>			 
			 
			 
			 
			 
<block name="script">

<script src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
<link rel="stylesheet" type="text/css" href="__STATIC__/uploadify/uploadify.css" media="all">
<script>



$(function(){

	
	setTimeout(function(){
		$("#content-pic").uploadify({
			'removeTimeout' : 0.5,
			"fileObjName"     : "download",
			'multi'    : true,
			'swf' 			: _STATIC_+'/uploadify/uploadify.swf',
			'uploader' 		: "{:U('File/upload',array('session_id'=>session_id()))}",
			'buttonText' 	: '<i class="icon-file"></i> 附件上传',
			'width' 		: '97',
			'height' 		: '34',
			'fileTypeExts'	: "{$extstr}",
			'onUploadSuccess' : function(file,data){
				var data= $.parseJSON(data);
				if(data.status){
					//alert(data.download.name);
					if(data.ext==1){
						var src = data.url || data.path;
						
						$(".note-editable").append('<img src="' + src + '" style="width:120px;height:120px;" />');
						}else if(data.ext==2){

							var src = data.data;
							//alert(src);
							$(".note-editable").append('[attach]'+data.info+'[/attach]');
						}else if(data.ext==3){

							var src = data.url;
							//alert(src);
							$(".note-editable").append('<img src="' + src + '" style="width:120px;height:120px;" />');
						}else{

							var src = data.data;
							//alert(src);
							$(".note-editable").append('[qnattach]'+data.info+'[/qnattach]');
						}
					//$("#content-editor").append('<img src=".' + src + '" width="120" height="120" />');
				} else {
				  layer.statusinfo(data.info,'error');	
				}
			}
		});
        




		},3);




	
});
</script>
<link rel="stylesheet" type="text/css" href="__JS__/editor/summernote.css" media="all">

<script src="__JS__/editor/summernote.js"></script>
<script src="__JS__/editor/plugin/summernote-ext-hello.js"></script>

<script src="__JS__/rainbow/rainbow.min.js"></script>
<link rel="stylesheet" type="text/css" href="__JS__/rainbow/themes/solarized-light.css" media="all">
<script src="__JS__/rainbow/language/generic.js"></script>
<script src="__JS__/rainbow/language/php.js"></script>

    <script>
    $(function(){
    	//var converter = new Showdown.converter();
    	//$("#content-editor").autosize();
    	//$("#content-editor").markdown({
    		
    	
    	//});
    	//$("#content-editor").on("keydown blur",function(event){ 
    		
    		
    		// var html=converter.makeHtml($(this).val());
   		  
 		   // $('#preview').html(html);
    		
    	//});
    	 //var Showdown = require('showdown');
    	    

    	  
    	    
   
    	      $("#content-editor").summernote(
    	    		  {
    	    			  toolbar: [
    	    			            ['style', ['style']],
    	    			            ['font', ['bold', 'italic', 'underline', 'clear']],
    	    			            
    	    			            ['color', ['color']],
    	    			            ['para', ['ul', 'ol', 'paragraph']],
    	    			            
    	    			            ['table', ['table']],
    	    			            ['insert', ['link', 'hr']],
    	    			            ['view', ['fullscreen', 'codeview']],
    	    			            ['help', ['help']],
    	    			            ['insert', ['hello','code']],
    	    			            ['history', ['undo','redo']]
    	    			          ],
height:400,

        	    		  }

    	    	      );	   
    	    
    	  //  alert(dd);
    	
    	
    });
   
    </script>

</block>